package com.Interface.service;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.Interface.dao.UserInfoMapper;
import com.Interface.entity.UserInfo;


@Service
public class UserInfoService {
	@Autowired
	UserInfoMapper userDao;
	
	public UserInfo selectByLoginId(String id){
		return userDao.selectByLoginId(id);
	}
	public UserInfo selectById(String id){
		return userDao.selectById(id);
	}
	
	
	public int updateByCreateTopic(UserInfo record){
		return userDao.updateByCreateTopic(record);
	}
	
	public Map<String, Object> getUserInfoById(int id){
		return userDao.getUserInfoById(id);
	}
	
	public int insertSelective(UserInfo record){
		return userDao.insertSelective(record);
	}
	
	public int updateByPrimaryKeySelective(UserInfo record){
		  return userDao.updateByPrimaryKeySelective(record);
	  }
	public int updateSign(int id){
		  return userDao.updateSign(id);
	  }
	public List<Map<String, Object>> selectIntegral(Map<String, Object> param){
		  return userDao.selectIntegral(param);
	  }
	public List<Map<String, Object>> selectNotice(Map<String, Object> param){
		  return userDao.selectNotice(param);
	  }
	public int oprIntegral(Map<String, Object> param){
		   int maxCnt = userDao.getMaxIntegralCnt(param);
		   if(maxCnt!=-1){
			  int curCnt = userDao.dayIntegralCnt(param);
			  if(curCnt>=maxCnt)
				  return 0;
		   }
		   int rlt = userDao.hasIntegralCount(param);
		   if(rlt==1){
			   rlt = userDao.insertIntegral(param);
			   rlt =userDao.updateIntegral(param);
		   }
		   return rlt ;
	  }
	//0-不可签到   1-可签到 
	public int isCanSign(Map<String, Object> param){
		 int maxCnt = userDao.getMaxIntegralCnt(param);
		   if(maxCnt!=-1){
			  int curCnt = userDao.dayIntegralCnt(param);
			  if(curCnt>=maxCnt)
				  return 0;
		   }
		   return 1;
	}
}
